package org.yu.team2023.flashdays.registries;

import net.minecraft.data.PackOutput;
import net.minecraft.world.item.Item;
import net.minecraftforge.common.data.LanguageProvider;
import net.minecraftforge.registries.ForgeRegistries;
import org.apache.commons.lang3.StringUtils;

import java.util.function.Consumer;

public class SimpleEnLangProvider extends LanguageProvider {
    String modid;
    public SimpleEnLangProvider(PackOutput output, String modid) {
        super(output, modid, "en_us");
        this.modid=modid;
    }

    @Override
    protected void addTranslations() {
        ForgeRegistries.ITEMS.getValues().stream().filter((item)->ForgeRegistries.ITEMS.getKey(item).getNamespace().equals(modid))
                .forEach(item -> add(item,toValue(ForgeRegistries.ITEMS.getKey(item).getPath())));
    }
    private String toValue(String value){
        StringBuilder stringBuilder=new StringBuilder();
        var split=value.split("_");
        for (int i = 0; i < split.length; i++) {
            stringBuilder.append(StringUtils.capitalize(split[i]));
            if(i+1!=split.length){
                stringBuilder.append(" ");
            }
        }
        return stringBuilder.toString();
    }
}
